<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib prefix="sys" uri="/WEB-INF/tld/sys.tld" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>分期列表</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
<div class="Wrapper">
    <div>
        <div id="pageInTab" class="pageInTab">
            <div tabid="tabA" title="分期申请" lselected="true">
                <form id="agentDetailForm">
                    <!--1 被保险人信息-->
                    <div class="fieldset1 tabel_col clearFix">
                        <div class="caption">
                            <span class="title">被保险人信息</span>
                        </div>

                        <div class="fieldBox col_33">
                            <div class="label">
                                <span class="requiredSymbol">*</span>被保险人类型
                            </div>
                            <div class="field">
                                <span id="insPerType" name="insPerType"></span>
                            </div>
                        </div>

                        <div class="fieldBox col_33">
                            <div class="label">被保险人姓名</div>
                            <div class="field">
                                <span id="nm" name="nm"></span>
                            </div>
                        </div>

                        <div class="fieldBox col_33">
                            <div class="label">客户身份证号</div>
                            <div class="field">
                                <span id="idNumber" name="idNumber"></span>
                            </div>
                        </div>

                        <%--<div class="fieldBox col_50">
                            <div class="label">身份证正面 /营业执照</div>
                            <div class="field">
                                <span id="fileIndent" name="fileIndent"></span>
                            </div>
                        </div>
                        <div class="fieldBox col_50">
                            <div class="label">身份证反面</div>
                            <div class="field">
                                <span id="fileIndentBack" name="fileIndentBack"></span>
                            </div>
                        </div>
                        <div class="fieldBox col_50">
                            <div class="label">行驶证正面</div>
                            <div class="field">
                                <span id="fileVehLince" name="fileVehLince"></span>
                            </div>
                        </div>
                        <div class="fieldBox col_50">
                            <div class="label">行驶证反面</div>
                            <div class="field">
                                <span id="fileVehLinceBack" name="fileVehLinceBack"></span>
                            </div>
                        </div>
                        <div class="fieldBox col_50">
                            <div class="label">行驶证反面</div>
                            <div class="field">
                                <span id="fileVehicleBackPath" name="fileVehicleBackPath"></span>
                            </div>
                        </div>--%>
                        <div class="fieldBox col_33"></div>
                        <div class="fieldBox col_33">
                            <div class="label" id="sfz11">
                                <span class="requiredSymbol">*</span>身份证正面
                            </div>
                            <div class="field" id="sfz12">
                                <c:if test="${ empty fileCertNoPath}">
                                    <img src="${defImg}"  onclick="showImg(event);" fileId="">
                                </c:if>
                                <c:if test="${ not empty fileCertNoPath}">
                                    <img id="idCardIn" onclick="showimg('idCardIn','${fileCertNoPath}')"
                                    src="${fileCertNoPath}" name="idCardIn" style="width:200px; height:100px;">
                                </c:if>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label" id="sfz21">
                                <span class="requiredSymbol">*</span>身份证反面
                            </div>
                            <div class="field" id="sfz22">
                                <c:if test="${ empty fileBackCertNoPath}">
                                    <img src="${defImg}"  onclick="showImg(event);" fileId="">
                                </c:if>
                                <c:if test="${ not empty fileBackCertNoPath}">
                                    <img id="idCardCons" onclick="showimg('idCardCons','${fileBackCertNoPath}')"
                                         src="${fileBackCertNoPath}" name="idCardCons" style="width:200px; height:100px;">
                                </c:if>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label" id="busLincePh">营业执照</div>
                            <div class="field" id="yyzz">
                                <c:if test="${ empty fileApplyBussPath}">
                                    <img src="${defImg}"  onclick="showImg(event);" fileId="">
                                </c:if>
                                <c:if test="${ not empty fileApplyBussPath}">
                                    <img id="busLincePh" onclick="showimg('busLincePh','${fileApplyBussPath}')"
                                         src="${fileApplyBussPath}" name="busLincePh" style="width:200px; height:100px;">
                                </c:if>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">
                                行驶证正面
                            </div>
                            <div class="field">
                                <%--<img id="vechPro" onclick="showimg('vechPro','${fileVehiclePath}')"
                                     src="${fileVehiclePath}" name="vechPro" style="width:200px; height:100px;">--%>
                                    <c:if test="${ empty fileVehiclePath}">
                                        <img src="${defImg}"  onclick="showImg(event);" fileId="">
                                    </c:if>
                                    <c:if test="${ not empty fileVehiclePath}">
                                        <img id="vechPro" onclick="showimg('vechPro','${fileVehiclePath}')"
                                             src="${fileVehiclePath}" name="vechPro" style="width:200px; height:100px;">
                                    </c:if>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">
                                行驶证反面
                            </div>
                            <div class="field">
                                <c:if test="${ empty fileVehicleBackPath}">
                                    <img src="${defImg}"  onclick="showImg(event);" fileId="">
                                </c:if>
                                <c:if test="${ not empty fileVehicleBackPath}">
                                    <img id="vechCons" onclick="showimg('vechCons','${fileVehicleBackPath}')"
                                         src="${fileVehicleBackPath}" name="vechCons" style="width:200px; height:100px;">
                                </c:if>
                            </div>
                        </div>
                    </div>
                    <!--2 车辆信息-->
                    <div class="fieldset1 tabel_col clearFix">
                        <div class="caption">
                            <span class="title">车辆信息</span>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">车牌号</div>
                            <div class="field">
                                <span id="plateNo" name="plateNo"></span>
                            </div>
                        </div>

                        <div class="fieldBox col_33">
                            <div class="label">车架号</div>
                            <div class="field">
                                <span id="vin" name="vin"></span>
                            </div>
                        </div>

                        <div class="fieldBox col_33">
                            <div class="label">发动机号</div>
                            <div class="field">
                                <span id="engineNo" name="engineNo"></span>
                            </div>
                        </div>

                        <div class="fieldBox col_33">
                            <div class="label">品牌型号</div>
                            <div class="field">
                                <span id="model" name="model"></span>
                            </div>
                        </div>

                    </div>
                    <!--3 保险信息-->
                    <div class="fieldset1 tabel_col clearFix">
                        <div class="caption">
                            <span class="title">保险信息</span>
                        </div>

                        <div class="fieldBox col_50">
                            <div class="label">保险公司</div>
                            <div class="field">
                                <span id="insCompNm" name="insCompNm"></span>
                            </div>
                        </div>

                        <div class="fieldBox col_50">
                            <div class="label">保险支公司</div>
                            <div class="field">
                                <span id="insCompSubNm" name="insCompSubNm"></span>
                            </div>
                        </div>

                        <div class="fieldBox col_50">
                            <div class="label">保险公司所属省份</div>
                            <div class="field">
                                <span id="insCompPro" name="insCompPro"></span>
                            </div>
                        </div>

                        <div class="fieldBox col_50">
                            <div class="label">保险公司所属城市</div>
                            <div class="field">
                                <span id="insCompCity" name="insCompCity"></span>
                            </div>
                        </div>


                        <div class="fieldBox col_50">
                            <div class="label">商业险保费</div>
                            <div class="field">
                                <span id="plcPriceNm" name="plcPriceNm"></span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">商业险保单号</div>
                            <div class="field">
                                <span id="plcNumber" name="plcNumber"></span>
                            </div>
                        </div>

                        <div class="fieldBox col_33">
                            <div class="label">交强险保费</div>
                            <div class="field">
                                <span id="insPriceNm" name="insPriceNm"></span>
                            </div>
                        </div>

                        <div class="fieldBox col_33">
                            <div class="label">交强险保单号</div>
                            <div class="field">
                                <span id="insNumber" name="insNumber"></span>
                            </div>
                        </div>

                        <div class="fieldBox col_50">
                            <div class="label">商业险保险期限</div>
                            <div class="field">
                                <span id="insBusBeginTms" name="insBusBeginTms"></span>
                            </div>
                        </div>

                        <div class="fieldBox col_33">
                            <div class="label">商业投保单</div>
                            <div class="field">
                                    <c:if test="${ empty filePolicyBPath}">
                                        <img src="${defImg}" onclick="showImg(event);" fileId="">
                                    </c:if>
                                    <c:if test="${ not empty filePolicyBPath}">
                                        <img id="busImgPath" onclick="showimg('busImgPath','${filePolicyBPath}')"
                                             src="${filePolicyBPath}" name="vechPro" style="width:200px; height:100px;">
                                    </c:if>
                            </div>
                        </div>

                        <div class="fieldBox col_50">
                            <div class="label">交强险保险期限</div>
                            <div class="field">
                                <span id="insBeginJQTms" name="insBeginJQTms"></span>
                            </div>
                        </div>

                        <div class="fieldBox col_33">
                            <div class="label">交强投保单</div>
                            <div class="field">
                                <c:if test="${ empty filePolicyJQPath}">
                                    <img src="${defImg}" onclick="showImg(event);" fileId="">
                                </c:if>
                                <c:if test="${ not empty filePolicyJQPath}">
                                    <img id="insPolicyJQPath$"
                                         onclick="showimg('insPolicyJQPath','${filePolicyJQPath}')"
                                         src="${filePolicyJQPath}" style="width:200px; height:100px;">
                                </c:if>
                            </div>
                        </div>


                    </div>
                </form>
                <div id="ligergrid1" class="sq-grid"></div>
            </div>
            <div tabid="tabB" title="报价方案" id="tabBId">
                <iframe frameborder="0" name="tabB" id="tabB" src=""></iframe>
            </div>
        </div>
    </div>
    <input type="hidden" id="applicationId" name="applicationId" value="${applicationId }">
</div>

<script type="text/javascript"
        src="<%=path%>/resource/lib/plugins/ajaxfileupload.js"></script>
<script>
    var form;
    var _appId = $("#applicationId").val();
    var pageInTab = null;
    var loadedTabs = []
    var pageInApp = {
        flag: true
    };
    $(function(){
        initForm();
        initData();
        initTab();
        form = liger.get("agentDetailForm");
    });

    //初始化form
    function initForm(){
        form = $("#agentDetailForm").ligerForm({
            validate : true
        });
    }

    function renderAmt(rowdata, rowindex, value) {
        if (StringUtils.isEmpty(value) || value <= 0){
            return "默认";
        }
        var h = "￥" + FormatMoney(value)
        return h;
    }
    // 获取申请表主键ID
    function getParams(){

    }

    //功能
    $(function(){

        //返回
        $("#back_Btn").click(function () {
            Remove_navTab();
        });

        //驳回
    });

    //初始化表单数据
    function initData(){
        var applicationId  = $("#applicationId").val();
        if(StringUtils.isEmpty(applicationId))return;
        var _url = '<%=path%>/inscare/insapplication/getApplicationId.do';
        AjaxUtils.ajaxGet(_url, {applicationId:applicationId}, initCallback);
    }

    //初始化回调
    function initCallback(msg){
        if(msg.success == 1){
            setData(msg.data);//设置数据
        }else{
            UIUtils.alertError(msg.info);
        }
    }

    function showImg(e){
        /* 		 e.preventDefault();
              var href = $(e.target).attr('href');
              if(!href){
                  return;
              }
              if(SQ.regs.img.test(href)){
                  SQ.imgPreview(href);
              } */
        e.preventDefault();
        var href = $(e.target).attr('src');
        if(!href){
            return;
        }
        if(SQ.regs.img.test(href)){
            var imgSrc = $(e.target).attr('src'),
                imgTit = $(e.target).attr('title');
            window.__ImgSrc = imgSrc;
            window.__ImgTit = imgTit;
            window.open('<%=path%>/project/prjbscinfo/imgWinOpen.do', '', 'location=yes, width=800, height=600');
        }
    }

    //修改时候设置页面数据  insTotalAmtNm
    function setData(data) {
        form.setData({
        });
        if (data.insPerType == 1) {//客户类型
            $("#insPerType").html("自然人");
            //自然人隐藏营业执照
            $("#yyzz").hide();
            $("#busLincePh").hide();
        } else if (data.insPerType == 2) {
            $("#insPerType").html("法人");
            //是法人隐藏身份证
            $("#sfz11").hide();
            $("#sfz12").hide();
            $("#sfz21").hide();
            $("#sfz22").hide();
        } else {
            $("#insPerType").html(" ");
        }
         //********************************车辆信息开始
         //
         if (StringUtils.isNotEmpty(data.plcBgTimeNm)) {
             $("#plcBgTimeNm").append(data.plcBgTimeNm);
         }
         if (StringUtils.isNotEmpty(data.plcEndTimeNm)) {
             $("#plcEndTimeNm").append(data.plcEndTimeNm);
         }
         //商业险起保时间
         if(StringUtils.isNotEmpty(data.plcBgTimeNm)){
             $("#insBusBeginTms").append(data.plcBgTimeNm +" 至 " +data.plcEndTimeNm);
         }
         if (StringUtils.isNotEmpty(data.plcPriceNm)) {
             $("#plcPriceNm").append(data.plcPriceNm);
         }
         if (StringUtils.isNotEmpty(data.plcNumber)) {
             $("#plcNumber").append(data.plcNumber);
         }
         //
         if (StringUtils.isNotEmpty(data.insBgTmBsNm)) {
             $("#insBgTmBsNm").append(data.insBgTmBsNm);
         }
         if (StringUtils.isNotEmpty(data.insEndTmBsNm)) {
             $("#insEndTmBsNm").append(data.insEndTmBsNm);
         }
         // 交强险 起保时间
         if(StringUtils.isNotEmpty(data.insEndTmBsNm)){
             $("#insBeginJQTms").append(data.insBgTmBsNm +" 至 " + data.insEndTmBsNm);
         }
         if (StringUtils.isNotEmpty(data.insNumber)) {
             $("#insNumber").append(data.insNumber);
         }
         if (StringUtils.isNotEmpty(data.insPriceNm)) {
             $("#insPriceNm").append(data.insPriceNm);
         }
         if (StringUtils.isNotEmpty(data.insPerNm)) {
             $("#nm").append(data.insPerNm);
         }
         if (StringUtils.isNotEmpty(data.certNo)) {
             $("#idNumber").append(data.certNo);
         }
         //plateNo
         if (StringUtils.isNotEmpty(data.plateNo)) {
             $("#plateNo").append(data.plateNo);
         }
      /*   if (StringUtils.isNotEmpty(data.insVehicleLicenseVO)) {
             $("#plateNo").append(data.insVehicleLicenseVO.plateNo);
         }*/
         if (StringUtils.isNotEmpty(data.insVehicleLicenseVO)) {
             $("#vin").append(data.insVehicleLicenseVO.vin);
         }
         if (StringUtils.isNotEmpty(data.insVehicleLicenseVO)) {
             $("#engineNo").append(data.insVehicleLicenseVO.engineNo);
         }
         if (StringUtils.isNotEmpty(data.insVehicleLicenseVO)) {
             $("#model").append(data.insVehicleLicenseVO.model);
         }
         //********************************车辆结束
         //保险公司名称
         if (StringUtils.isNotEmpty(data.insCompNm)) {
             $("#insCompNm").append(data.insCompNm);
         }
         if (StringUtils.isNotEmpty(data)) {
             $("#insPerType").append(data.insPerTypeNm);
         }
         //区域-省名称
         if (StringUtils.isNotEmpty(data.rgnPrNm)) {
             $("#insCompPro").append(data.rgnPrNm);
         }
         //区域-市名称
         if (StringUtils.isNotEmpty(data.rgnCyNm)) {
             $("#insCompCity").append(data.rgnCyNm);
         }
         if (StringUtils.isNotEmpty(data)) {
             $("#certNo").append(data.certNo);
         }
         if (StringUtils.isNotEmpty(data)) {
             $("#fstPer").append(data.fstPer);
         }
         //保险支公司
         if (StringUtils.isNotEmpty(data.insCompSubNm)) {
             $("#insCompSubNm").append(data.insCompSubNm);
         }
        //交强险净保费
        if(StringUtils.isNotEmpty(data.insQuoteInfoVO.insCompNetPremiumNm)) {
            $("#insJQDicAmt").append(data.insQuoteInfoVO.insCompNetPremiumNm);
        }
		//保单投递表开始 insDeliveryInfoVO
        if(StringUtils.isNotEmpty(data.insDeliveryInfoVO)){
            $("#recipNm").append(data.insDeliveryInfoVO.recipientsNm);
        }
        if(StringUtils.isNotEmpty(data.insDeliveryInfoVO)){
            $("#recipTel").append(data.insDeliveryInfoVO.recipientsTel);
        }
        if(StringUtils.isNotEmpty(data.insDeliveryInfoVO)){
            $("#recipAddress").append(data.insDeliveryInfoVO.recipientsAddr);
        }
        if(StringUtils.isNotEmpty(data.insDeliveryInfoVO)){
            $("#expCompNm").append(data.insDeliveryInfoVO.expressCompanyNm);
        }
          if(StringUtils.isNotEmpty(data.insDeliveryInfoVO)){
            $("#courNumber").append(data.insDeliveryInfoVO.courierNumber);
        }
        //保单投递表结束
		$("#oper").append(data.usrNm);
		
	};

    //跳转到查询账单详情页面
    function showimg(tab_id, url) {
        if (url != '') {
            Add_navTab('INS_VEHICLE_INFO_IMG' + tab_id, '保单照片查看', url);
        }
    }



    //新增回调
    function addCallback(msg){
        if(msg.success == 1){
            UIUtils.alertSuccess(msg.info);
            //parent.grid.reload();
            //frameElement.dialog.close();
        }else{
            UIUtils.alertError(msg.info);
        }
    }

    //初始化Tab
    function initTab() {
        pageInTab = $("#pageInTab").ligerTab({
            height: 'auto',
            contextmenu: false,
            minIframeHeight: GET_minIframeHeight(),
            onBeforeSelectTabItem: function (tabid) {
                if (tabid != "tabA") {
                    if (StringUtils.isEmpty(_appId)) {
                        UIUtils.alertWarning("分期申請信息有误，请核对！");
                        return false;
                    }
                }
            },
            onAfterSelectTabItem: function (tabid) {
                if (loadedTabs.indexOf(tabid) < 0) {
                    if (tabid != "tabA") {
                        if (null == _appId) {
                            UIUtils.alertWarning("请确认用户信息");
                            return false; //验证不通过，不执行以下代码
                        }
                    }
                    loadedTabs.push(tabid);
                    switch (tabid) {
                        case "tabB":
                            pageInTab.setTabItemSrc(tabid, "<%=path%>/inscare/insapplication/toPricingPage.do?applicationId=" + _appId);
                            break;
                    }
                }
                ;
                SetIframe_height();
            }
        });

        $.extend(true, pageInApp, {
            pageInTab: pageInTab
        });
    };

</script>

</body>
</html>
